// Screen.java
// Represents the screen of the ATM
import java.util.*;
import java.text.*;

public class Screen {
	Date date = new Date(); // date
	SimpleDateFormat ft = new SimpleDateFormat("HH:mm dd/MM-yyyy"); //formats the date

	// Method for defining the output of the screen bottom
	public void printBot() {
		System.out.print("|");
		for (int i = 0; i < 88; i++) {
			System.out.print(" ");
		}
		System.out.println("|");
		System.out.print("+");
		for (int i = 0; i < 88; i++) {
			System.out.print("-");
		}
		System.out.println("+");
		System.out.println("");

	} // end method printBot

	// Method for defining the output of the screen top
	public void printTop() {
		int strLen = 16;
		int spaces = (88 - strLen) / 2;
		System.out.print("+");
		for (int i = 0; i < spaces; i++) {
			System.out.print("-");
		} // ends for
		System.out.print(ft.format(date));
		for (int i = 0; i < spaces; i++) {
			System.out.print("-");
		} // ends for
		System.out.println("+");
		System.out.printf("|");
		for (int i = 0; i < 88; i++) {
			System.out.print(" ");
		} // end for loop
		System.out.println("|");

	} // end method printTop

	// method for displaying the messages centered
	public void printMessage(String message) {
		int strLen = message.length();
		int spaces = (88 - strLen) / 2;
		System.out.print("|");
		for (int i = 0; i < spaces; i++) {
			System.out.print(" ");
		}
		System.out.print(message);
		for (int i = 0; i < spaces; i++) {
			System.out.print(" ");
		}
		if ((88 - strLen) % 2 == 1) {
			System.out.print(" ");
		}
		System.out.println("|");

	} // end method printMessage

	// returns blank line
	public void printBlank() {
		System.out.print("|");
		for (int i = 0; i < 88; i++) {
			System.out.print(" ");
		}
		System.out.println("|");
	} // end method printBlank

	// displays a message without a carriage return
	public void displayMessage(String message) {
		System.out.print(message);
	} // end method displayMessage

	// display a message with a carriage return
	public void displayMessageLine(String message) {
		System.out.println(message);
	} // end method displayMessageLine

} // end class Screen

/**************************************************************************
 * (C) Copyright 1992-2012 by Deitel & Associates, Inc. and * Pearson Education,
 * Inc. All Rights Reserved. * * DISCLAIMER: The authors and publisher of this
 * book have used their * best efforts in preparing the book. These efforts
 * include the * development, research, and testing of the theories and programs
 * * to determine their effectiveness. The authors and publisher make * no
 * warranty of any kind, expressed or implied, with regard to these * programs
 * or to the documentation contained in these books. The authors * and publisher
 * shall not be liable in any event for incidental or * consequential damages in
 * connection with, or arising out of, the * furnishing, performance, or use of
 * these programs. *
 *************************************************************************/
